package demoutil

import "fmt"
import "strings"

// 1. Console I/O
type CMD struct {
	alive   bool
	me_type string
	todo    []string
}

func (cmd *CMD) GetTodo() []string {
	return cmd.todo
}
func (cmd *CMD) GetStatus() bool {
	return cmd.alive
}

func (cmd *CMD) ParseInput(input string) bool {
    //fmt.Printf("cmd: %v -> ",input)
	input = strings.TrimSpace(input)
    //fmt.Println(input)
	// basic console I/O
	execute := false
	switch input {
	case "", "\n":
		fmt.Printf("")
	case "q", "quit":
		fmt.Println("Bye")
		cmd.alive = false
	case "ip":
        fmt.Println("IP: ",getIP())
	// only support put
	default:
		cmd.todo = strings.Split(input, " ")
		execute = true
	}
	return execute
}

func Make_cmd() CMD {
	cmd := CMD{}
	cmd.alive = true
	return cmd
}


